package com.ys.homework;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author CodeYang
 * @Description
 * @Date 2020/12/14 20:39
 */
public class 打印学生信息08 {

    public static void main(String[] args) {
        Student student1 = new Student("001", "小王1", '男', 18, 80.0);
        Student student2 = new Student("002", "小王2", '男', 18, 60.0);
        Student student3 = new Student("003", "小王3", '男', 18, 100.0);
        Student student4 = new Student("004", "小王4", '男', 18, 70.0);
        Student student5 = new Student("005", "小王5", '男', 18, 40.0);
        List<Student> arr = new ArrayList<Student>(5);
        arr.add(student1);
        arr.add(student2);
        arr.add(student3);
        arr.add(student4);
        arr.add(student5);
        // 输出
        for (int i = 0; i < arr.size(); i++) {
            String str = arr.get(i).getsNO() + "\t" + arr.get(i).getsName() + "\t" + arr.get(i).getsSex() + "\t" + arr.get(i).getsAge() + "\t" + arr.get(i).getsJava();
            System.out.println(str);
        }
        double sum = 0;
        // 计算机平均值
        double max =arr.get(0).getsJava();
        for (int i = 0; i < arr.size(); i++) {
            if (arr.get(i).getsJava()>max)
            {}
            sum += arr.get(i).getsJava();
        }

        System.out.println("平均成绩为:" + (sum / arr.size()));

    }
}
